//
//  IntegralMallViewController.m
//  lmq
//
//  Created by 马田成 on 2017/4/2.
//  Copyright © 2017年 yuanxin. All rights reserved.
//

#import "IntegralMallViewController.h"
#import "IntegralMallCollectionViewCell.h"
#import "SDCycleScrollView.h"
#import "Masonry.h"
#import "IntegralMallDetailsViewController.h"
#import "HomeIntegralMallModel.h"
#import "IntegralMallParticipateView.h"
#import "IntegralMallClearingVC.h"
#import "addressViewController.h"

#import "picYiYuanViewController.h"


#import "IntegralOtherShopXQViewController.h"

@interface IntegralMallViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout,SDCycleScrollViewDelegate>
{
    UIView *grayView;
    NSInteger zhuangTai;
    
    
}
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic,strong) SDCycleScrollView *cycleScrollView;
@property (nonatomic, strong) UILabel *labelOfPop;//人气
@property (nonatomic, strong) UILabel *labelOfNew;//最新
@property (nonatomic, strong) UILabel *labelOfProgress;//进度
@property (nonatomic, strong) UILabel *labelOfPopulation;//人数
@property (nonatomic, strong) IntegralMallParticipateView *nowView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) NSMutableArray *picArr;
@property (nonatomic, strong) NSMutableArray *arr22;

@property (nonatomic, strong) NSMutableDictionary *shopDic;
@property (nonatomic, strong) UICollectionReusableView *headView;
@property (nonatomic, strong) UIView *viewOfHeader;
@property (nonatomic, strong) UIButton *buttonOfPopulation;

@property (nonatomic, strong) UIImageView *imageView1;
@property (nonatomic, strong) UIImageView *imageView2;
@property (nonatomic, strong) UIImageView *imageView3;
@property (nonatomic, strong) UIImageView *imageView4;
@end

@implementation IntegralMallViewController
- (void)viewWillAppear:(BOOL)animated{

    [self creationDate];
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];

    [self configLayout];
    
    
}
- (void)configLayout{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.minimumLineSpacing = 10;
    layout.minimumInteritemSpacing = 10;
    layout.itemSize = CGSizeMake((DEF_SCREEN_WIDTH - 30) / 2, 260);
    //直接布局 上下左右
    layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
    //头部
    layout.headerReferenceSize = CGSizeMake(0, 350);
    
   
    
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64 - 49 - 42) collectionViewLayout:layout];
    [self.view addSubview:self.collectionView];
    //
    [self.collectionView layoutIfNeeded];
    //    self.automaticallyAdjustsScrollViewInsets = NO;
    self.collectionView.pagingEnabled = NO;
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    
    
    
    [self.collectionView registerNib:[UINib nibWithNibName:@"IntegralMallCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"IntegralMallCollectionViewCell"];
    
    
    [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionViewHeader"];
    
    self.collectionView.showsHorizontalScrollIndicator = NO;
    
    //    self.collectionView.bounces = NO;
    self.collectionView.backgroundColor = [UIColor whiteColor];
    
    
}
- (void)creationDate{
    
    _dataArr = [[NSMutableArray alloc]init];
    _picArr = [[NSMutableArray alloc] init];
    _arr22 = [[NSMutableArray alloc]  init];
    
    
    //    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    //    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];
    //    NSString *memberId = [PublicFunction getConfigWithKey:@"uid"];
    //    [productParams setValue:tokenStr forKey:@"token"];
    //    [productParams setValue:@"1" forKey:@"type"];
    //    [productParams setValue:memberId forKey:@"member_id"];
    
    [[MNetworkHandler sharedInstance]conURL:Home_OneshowIndex
                                networkType:NetWorkPOST
                                     params:nil
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       _picArr = [returnData objectForKey:@"carousel"];
                                       
                                       NSMutableDictionary *dict1 = [returnData objectForKey:@"shop"];
                                       _arr22 = [returnData objectForKey:@"shop"];
                                       
                                       for (NSDictionary *dic in dict1 ) {
                                           HomeIntegralMallModel *model = [[HomeIntegralMallModel alloc]init];
                                           [model setValuesForKeysWithDictionary:dic];
                                           [_dataArr addObject:model];
                                       }
                                       
                                       
                                       [self.collectionView reloadData];
                                   }
                                   else {
//                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];
    
}



//创建头视图
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
           viewForSupplementaryElementOfKind:(NSString *)kind
                                 atIndexPath:(NSIndexPath *)indexPath {
    
    
    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
        
    
    self.headView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionViewHeader"forIndexPath:indexPath];
        
    for (UIView *view in self.headView.subviews) {
            [view removeFromSuperview];
        }
    
    self.viewOfHeader = [[UIView alloc] init];
    self.viewOfHeader.frame = self.headView.frame;
    [self.headView addSubview:self.viewOfHeader];
    

    
    self.headView.backgroundColor = [UIColor whiteColor];
//    NSArray *arrMu = @[@"liyi",@"liyi",@"liyi"];
    self.cycleScrollView=[SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, 200) imageNamesGroup:self.picArr];
    self.cycleScrollView.backgroundColor=[UIColor greenColor];
    self.cycleScrollView.pageControlAliment=SDCycleScrollViewPageContolAlimentCenter;
    self.cycleScrollView.delegate = self;
    self.cycleScrollView.pageDotColor = [UIColor grayColor]; // 自定义分页控件小圆标颜色
    
    
    NSMutableArray *myarr=[[NSMutableArray alloc]init];
    for (int i=0; i<self.picArr.count; i++) {
        
        NSString *str=[self.picArr[i] objectForKey:@"carousel"];
        NSString *urlN=manage(AP_HOST, str);
        NSString *strUrl = [urlN stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
        [myarr addObject:strUrl];
    }
        if (myarr.count == 0) {
            NSArray *arrOfPic =@[@"http://112.74.36.208/Uploads/lunbo.jpg"];

            [self.cycleScrollView setLocalizationImageNamesGroup:arrOfPic];
            
        }else {
        
            
            [self.cycleScrollView setLocalizationImageNamesGroup:myarr];
        }
    [self.cycleScrollView reloadInputViews];
    self.cycleScrollView.currentPageDotImage=[UIImage imageNamed:@"hei"];
    self.cycleScrollView.pageDotImage=[UIImage imageNamed:@"hui"];
    self.cycleScrollView.placeholderImage = [UIImage imageNamed:@""];
    [self.viewOfHeader addSubview:self.cycleScrollView];
    
    
    
    
    //人气button
    UIButton *buttonOfPop = [[UIButton alloc] init];
    [self.viewOfHeader addSubview:buttonOfPop];
    buttonOfPop.titleLabel.font = [UIFont systemFontOfSize:14];
    [buttonOfPop setTitle:@"人气" forState:UIControlStateNormal];
    [buttonOfPop setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
//    [buttonOfPop setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    buttonOfPop.tag = 11;
    [buttonOfPop addTarget:self action:@selector(changeData:) forControlEvents:UIControlEventTouchUpInside];
    
    
    buttonOfPop.frame = CGRectMake(15, 200, (DEF_SCREEN_WIDTH - 60) / 4, 40);
    self.labelOfPop = [[UILabel alloc] init];
    [buttonOfPop addSubview:self.labelOfPop];
    [self.labelOfPop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(buttonOfPop.mas_bottom).with.offset(5);
        make.left.equalTo(buttonOfPop.mas_left);
        make.width.equalTo(buttonOfPop.mas_width);
        make.height.offset(2);
        
    }];
    self.labelOfPop.backgroundColor = [UIColor blackColor];
    
    
    
    //最新button
    UIButton *buttonOfNew = [[UIButton alloc] init];
    [self.viewOfHeader addSubview:buttonOfNew];
    buttonOfNew.titleLabel.font = [UIFont systemFontOfSize:14];
    [buttonOfNew setTitle:@"最新" forState:UIControlStateNormal];
    [buttonOfNew setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    [buttonOfNew setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    buttonOfNew.tag = 12;
    [buttonOfNew addTarget:self action:@selector(changeData:) forControlEvents:UIControlEventTouchUpInside];
    buttonOfNew.frame = CGRectMake(30 + (DEF_SCREEN_WIDTH - 100) / 4, 200, (DEF_SCREEN_WIDTH - 60) / 4, 40);
    self.labelOfNew = [[UILabel alloc] init];
    [buttonOfNew addSubview:self.labelOfNew];
    [self.labelOfNew mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(buttonOfNew.mas_bottom).with.offset(5);
        make.left.equalTo(buttonOfNew.mas_left);
        make.width.equalTo(buttonOfNew.mas_width);
        make.height.offset(2);
        
    }];
    self.labelOfNew.backgroundColor = [UIColor blackColor];
  
    
    //进度button
    UIButton *buttonOfProgress = [[UIButton alloc] init];
    [self.viewOfHeader addSubview:buttonOfProgress];
     buttonOfProgress.titleLabel.font = [UIFont systemFontOfSize:14];
    [buttonOfProgress setTitle:@"进度" forState:UIControlStateNormal];
    [buttonOfProgress setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    [buttonOfProgress setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    buttonOfProgress.tag = 13;
    
    [buttonOfProgress addTarget:self action:@selector(changeData:) forControlEvents:UIControlEventTouchUpInside];
    
    buttonOfProgress.frame = CGRectMake(45 +(DEF_SCREEN_WIDTH - 100) / 4 * 2, 200, (DEF_SCREEN_WIDTH - 60) / 4, 40);
    self.labelOfProgress = [[UILabel alloc] init];
    [buttonOfProgress addSubview:self.labelOfProgress];
    [self.labelOfProgress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(buttonOfProgress.mas_bottom).with.offset(5);
        make.left.equalTo(buttonOfProgress.mas_left);
        make.width.equalTo(buttonOfProgress.mas_width);
        make.height.offset(2);
        
    }];
    self.labelOfProgress.backgroundColor = [UIColor blackColor];
    
    
    
    //总需人数button
    self.buttonOfPopulation = [[UIButton alloc] init];
    [self.viewOfHeader addSubview:self.buttonOfPopulation];
        
        UILabel *labelOfRenShu = [[UILabel alloc] init];
        labelOfRenShu.text = @"总需人数";
        [self.buttonOfPopulation addSubview:labelOfRenShu];
        labelOfRenShu.font = [UIFont systemFontOfSize:14];
        [labelOfRenShu mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.buttonOfPopulation).with.offset(10);
            make.left.equalTo(self.buttonOfPopulation).with.offset(2);
            make.bottom.equalTo(self.buttonOfPopulation).with.offset(-10);
            make.right.equalTo(self.buttonOfPopulation).with.offset(-5);
            
        }];
    [self.buttonOfPopulation addTarget:self action:@selector(changeData:) forControlEvents:UIControlEventTouchUpInside];
    
    self.buttonOfPopulation.frame = CGRectMake(60+(DEF_SCREEN_WIDTH - 100) / 4 * 3, 200, (DEF_SCREEN_WIDTH - 60) / 4, 40);

    self.labelOfPopulation = [[UILabel alloc] init];
    [self.buttonOfPopulation addSubview:self.labelOfPopulation];
    [self.labelOfPopulation mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.buttonOfPopulation.mas_bottom).with.offset(5);
        make.left.equalTo(self.buttonOfPopulation.mas_left);
        make.width.equalTo(self.buttonOfPopulation.mas_width);
        make.height.offset(2);
        
    }];
        
    self.labelOfPopulation.backgroundColor = [UIColor blackColor];
        self.buttonOfPopulation.tag = 14;
        
            self.imageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"up_sel"]];
            [self.buttonOfPopulation addSubview:self.imageView1];
            [self.imageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.buttonOfPopulation).with.offset(12);
                make.width.offset(5);
                make.height.offset(7);
                make.right.equalTo(self.buttonOfPopulation).with.offset(-3);
                
            }];
            
            self.imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"down_nor"]];
            [self.buttonOfPopulation addSubview:self.imageView2];
            [self.imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.equalTo(self.buttonOfPopulation).with.offset(-12);
                make.width.offset(5);
                make.height.offset(7);
                make.right.equalTo(self.buttonOfPopulation).with.offset(-3);
                
            }];
  
            self.imageView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"up_nor"]];
            [self.buttonOfPopulation addSubview:self.imageView3];
            [self.imageView3 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.buttonOfPopulation).with.offset(12);
                make.width.offset(5);
                make.height.offset(7);
                make.right.equalTo(self.buttonOfPopulation).with.offset(-3);
                
            }];
            
            self.imageView4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"down_sel"]];
            [self.buttonOfPopulation addSubview:self.imageView4];
            [self.imageView4 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.equalTo(self.buttonOfPopulation).with.offset(-12);
                make.width.offset(5);
                make.height.offset(7);
                make.right.equalTo(self.buttonOfPopulation).with.offset(-3);
                
            }];

            
        
        self.imageView1.hidden = YES;
        self.imageView2.hidden = YES;
        self.imageView3.hidden = YES;
        self.imageView4.hidden = YES;
        
        
        
        
        
        
        
    
 //   默认状态
    self.labelOfPop.hidden = YES;
    self.labelOfNew.hidden = YES;
    self.labelOfProgress.hidden = YES;
    self.labelOfPopulation.hidden = YES;
    

    return self.headView;
    }
    
        return self.headView;
        
    
    
}
#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", index);
    
    //    NSDictionary *dict=arrLunbo[index];
    //    NSString *str1=[dict objectForKey:@"height"];
    //    NSString *str2=[dict objectForKey:@"src"];
    //    NSString *str3=[dict objectForKey:@"url"];
    //    NSString *str4=[dict objectForKey:@"width"];
    
    if (self.picArr.count == 0) {
        
        picYiYuanViewController *vc=[[picYiYuanViewController alloc]init];
        
        vc.hidesBottomBarWhenPushed=YES;
        
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}


// 设置section头视图的参考大小，与tableheaderview类似
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout
referenceSizeForHeaderInSection:(NSInteger)section {
    
    if (section == 0) {
        return CGSizeMake(self.view.frame.size.width, 260);
    }
    else {
        return CGSizeMake(0, 0);
    }
}
//类别
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
    
}
//数量
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    
    return self.dataArr.count;
    
    
}
//内容

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    IntegralMallCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"IntegralMallCollectionViewCell" forIndexPath:indexPath];
    
    
    HomeIntegralMallModel *model = self.dataArr[indexPath.row];
    cell.modelOfIntegral = model;
//    [cell.ImmediatelyButton addTarget:self action:@selector(buyNow:) forControlEvents:UIControlEventTouchUpInside];
    
    [cell callBackEditBlock:^{
        
        NSString *str = model.price;

        NSInteger aaaa = model.purchase - model.buy;
        NSString *strShopid = model.shop_id;
        
        [self editWorkExperienceWithModel:str other:aaaa otherShopid:strShopid];
        
    }];

    
    
    
    return cell;
    
    
    
}
//弹窗
- (void)editWorkExperienceWithModel:(NSString *)str other:(NSInteger )num otherShopid:(NSString *)shopid{
    grayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height+64)];
    grayView.backgroundColor = [UIColor blackColor];
    grayView.alpha = 0.4;
    grayView.tag = 111;
    //    [[UIApplication sharedApplication].keyWindow addSubview:grayView];
    [self.view addSubview:grayView];
    
    _nowView = [[NSBundle mainBundle] loadNibNamed:@"IntegralMallParticipateView" owner:self options:nil].lastObject;
    [self.view addSubview:self.nowView];
    [self.nowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).with.offset(-40);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.offset(310);
        
    }];
    self.nowView.backgroundColor = [UIColor whiteColor];
    
    
    [self.nowView.canceButton addTarget:self action:@selector(canceClick) forControlEvents:UIControlEventTouchUpInside];
    self.nowView.nowPurchaseButton.tag = [shopid intValue];
    self.nowView.price = str;
    self.nowView.numberLabel = [NSString stringWithFormat:@"%ld", (long)num];
    
//    [self.nowView.nowPurchaseButton addTarget:self action:@selector(nowingPurchaseClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.nowView callBackEditBlock:^{
        
        NSString *str1 = str;
        
        NSInteger aaaa = num;
        NSString *strShopid = shopid;
        
        [self editWorkExperienceWith:str1 other:aaaa otherShopid:strShopid];
    }];
    
    
    
    
    // 单击的 Recognizer
    UITapGestureRecognizer* singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(SingleTap:)];
    
    
    [grayView addGestureRecognizer:singleRecognizer];

}
//点击隐藏view
-(void)SingleTap:(UITapGestureRecognizer*)recognizer  {
    
    
    self.nowView.hidden = YES;
    grayView.hidden = YES;
    
    
}
- (void)canceClick{
    
    self.nowView.hidden = YES;
    grayView.hidden = YES;
    
}
//立即购买view
- (void)editWorkExperienceWith:(NSString *)str other:(NSInteger )num otherShopid:(NSString *)shopid{
    
    NSMutableDictionary *productParams = [[NSMutableDictionary alloc] init];
  
    [productParams setValue:shopid forKey:@"shop_id"];
    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];
    NSString *memberId = [PublicFunction getConfigWithKey:@"uid"];
    [productParams setValue:tokenStr forKey:@"token"];
    [productParams setValue:memberId forKey:@"member_id"];
//    [productParams setValue:self.nowView.numberTextField.text forKey:@"num"];
    if ([self.nowView.numberTextField.text intValue] >= [self.nowView.numberLabel intValue]) {
        [productParams setValue:self.nowView.numberLabel forKey:@"num"];
        
    }else {
        [productParams setValue:self.nowView.numberTextField.text forKey:@"num"];
        
    }
    [[MNetworkHandler sharedInstance]conURL:Home_OnebuyToAccount
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       IntegralMallClearingVC *vc = [[IntegralMallClearingVC alloc] init];
                                       
                                       vc.num = self.nowView.numberTextField.text;
                                       
                                       vc.shop_id = shopid;
                                       
                                       vc.hidesBottomBarWhenPushed = YES;
                                       [self.navigationController pushViewController:vc animated:YES];
                                       
                                       
                                       NSLog(@"%@", returnData);
                                       
                                   }
                                   else if ([[returnData objectForKey:@"code"]intValue]==-3){
                                       
                                       addressViewController *vc = [[addressViewController alloc] init];
                                       
                                       [self.navigationController pushViewController:vc animated:YES];
                                       
                                       
                                   } else {
                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                       
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];
    
    
    
    
    
}


//点击
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

    IntegralMallDetailsViewController *vc = [[IntegralMallDetailsViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    IntegralOtherShopXQViewController *otherVC = [[IntegralOtherShopXQViewController alloc] init];
    otherVC.hidesBottomBarWhenPushed = YES;
    
    
     HomeIntegralMallModel *model = self.dataArr[indexPath.row];
    
    if ([model.status isEqualToString:@"0"]) {
        vc.shopid = model.shop_id;
        vc.addTime = model.add_time;
        
        
        [self.navigationController pushViewController:vc animated:YES];
    }else {
    
        otherVC.shopid = model.shop_id;
        vc.addTime = model.add_time;
        
        [self.navigationController pushViewController:otherVC animated:YES];
        
    
    }
    
    
    
    
    
    
}
- (void)changeData:(UIButton *)sender{
//   [self.collectionView reloadData];
    if (sender.tag == 11) {
        
        
        [[MNetworkHandler sharedInstance]conURL:Home_OneshowIndex
                                    networkType:NetWorkPOST
                                         params:nil
                                       delegate:nil
                                        showHUD:NO
                                   successBlock:^(id returnData) {
                                       if ([[returnData objectForKey:@"code"]intValue]==1) {
                                           
                                           [self.dataArr removeAllObjects];
                                           [self.arr22 removeAllObjects];
                                           
                                           NSMutableDictionary *dict1 = [returnData objectForKey:@"shop"];
                                           
                                           _arr22 = [returnData objectForKey:@"shop"];
                                           for (NSDictionary *dic in dict1 ) {
                                               HomeIntegralMallModel *model = [[HomeIntegralMallModel alloc]init];
                                               [model setValuesForKeysWithDictionary:dic];
                                               [_dataArr addObject:model];
                                           }
                                           
                                     
                                           [self.collectionView reloadData];
                                       }
                                       else {
//                                           [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                       }
                                   } failureBlock:^(NSError *error) {
                                       NSLog(@"%@",error);
                                       [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                                   }];

 
        self.labelOfPop.hidden = NO;
        self.labelOfNew.hidden = YES;
        self.labelOfProgress.hidden = YES;
        self.labelOfPopulation.hidden = YES;
        sender.selected = !sender.selected;
//        [self.viewOfHeader removeFromSuperview];
        
    }else if (sender.tag == 12) {
        
       
        
        NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];

        [productParams setValue:@"1" forKey:@"type"];

        
        [[MNetworkHandler sharedInstance]conURL:Home_OneOtherIndex
                                    networkType:NetWorkPOST
                                         params:productParams
                                       delegate:nil
                                        showHUD:NO
                                   successBlock:^(id returnData) {
                                       if ([[returnData objectForKey:@"code"]intValue]==1) {
                                           [self.dataArr removeAllObjects];
                                           [self.arr22 removeAllObjects];
                                           
                                           NSMutableDictionary *dict1 = [returnData objectForKey:@"data"];
                                           _arr22 = [returnData objectForKey:@"data"];
                                           
                                           for (NSDictionary *dic in dict1 ) {
                                               HomeIntegralMallModel *model = [[HomeIntegralMallModel alloc]init];
                                               [model setValuesForKeysWithDictionary:dic];
                                               [_dataArr addObject:model];
                                           }
                                           
                                           
                                          
                                           
                                           [self.collectionView reloadData];
                                       }
                                       else {
//                                           [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                       }
                                   } failureBlock:^(NSError *error) {
                                       NSLog(@"%@",error);
                                       [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                                   }];

        
        
        self.labelOfPop.hidden = YES;
        self.labelOfNew.hidden = NO;
        self.labelOfProgress.hidden = YES;
        self.labelOfPopulation.hidden = YES;
        sender.selected = !sender.selected;
     //   sender.backgroundColor = [UIColor redColor]
//         [self.viewOfHeader removeFromSuperview];
    
    }else if (sender.tag == 13) {
        NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
        
        [productParams setValue:@"2" forKey:@"type"];
        
        
        [[MNetworkHandler sharedInstance]conURL:Home_OneOtherIndex
                                    networkType:NetWorkPOST
                                         params:productParams
                                       delegate:nil
                                        showHUD:NO
                                   successBlock:^(id returnData) {
                                       if ([[returnData objectForKey:@"code"]intValue]==1) {
                                           [self.dataArr removeAllObjects];
                                        
                                           [self.arr22 removeAllObjects];
                                           
                                           NSMutableDictionary *dict1 = [returnData objectForKey:@"data"];
                                           _arr22 = [returnData objectForKey:@"data"];
                                           
                                           for (NSDictionary *dic in dict1 ) {
                                               HomeIntegralMallModel *model = [[HomeIntegralMallModel alloc]init];
                                               [model setValuesForKeysWithDictionary:dic];
                                               [_dataArr addObject:model];
                                           }
                                           
                                           
                                           [self.collectionView reloadData];
                                       }
                                       else if ([[returnData objectForKey:@"code"]intValue]==-1){
//                                           [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                       }
                                   } failureBlock:^(NSError *error) {
                                       NSLog(@"%@",error);
                                       [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                                   }];

        self.labelOfPop.hidden = YES;
        self.labelOfNew.hidden = YES;
        self.labelOfProgress.hidden = NO;
        self.labelOfPopulation.hidden = YES;
        sender.selected = !sender.selected;
//         [self.viewOfHeader removeFromSuperview];
    
    } else if (sender.tag == 14){
        
        if (sender.selected) {
            
            self.imageView1.hidden = NO;
            self.imageView2.hidden = NO;
            self.imageView3.hidden = YES;
            self.imageView4.hidden = YES;
            NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
            
            [productParams setValue:@"3" forKey:@"type"];
            
            
            [[MNetworkHandler sharedInstance]conURL:Home_OneOtherIndex
                                        networkType:NetWorkPOST
                                             params:productParams
                                           delegate:nil
                                            showHUD:NO
                                       successBlock:^(id returnData) {
                                           if ([[returnData objectForKey:@"code"]intValue]==1) {
                                               [self.dataArr removeAllObjects];
                                               [self.arr22 removeAllObjects];
                                               
                                               NSMutableDictionary *dict1 = [returnData objectForKey:@"data"];
                                               _arr22 = [returnData objectForKey:@"data"];
                                               
                                               for (NSDictionary *dic in dict1 ) {
                                                   HomeIntegralMallModel *model = [[HomeIntegralMallModel alloc]init];
                                                   [model setValuesForKeysWithDictionary:dic];
                                                   [_dataArr addObject:model];
                                               }
                                               
                                               
                                               
                                            
                                                   [self.collectionView reloadData];
                                           }
                                           else if ([[returnData objectForKey:@"code"]intValue]==-1){
//                                               [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                           }
                                       } failureBlock:^(NSError *error) {
                                           NSLog(@"%@",error);
                                           [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                                       }];
            
            self.labelOfPop.hidden = YES;
            self.labelOfNew.hidden = YES;
            self.labelOfProgress.hidden = YES;
            self.labelOfPopulation.hidden = NO;
            sender.selected = !sender.selected;
            
            
        }else {
            
            self.imageView1.hidden = YES;
            self.imageView2.hidden = YES;
            self.imageView3.hidden = NO;
            self.imageView4.hidden = NO;
            
            NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
            
            [productParams setValue:@"4" forKey:@"type"];
            
            
            [[MNetworkHandler sharedInstance]conURL:Home_OneOtherIndex
                                        networkType:NetWorkPOST
                                             params:productParams
                                           delegate:nil
                                            showHUD:NO
                                       successBlock:^(id returnData) {
                                           if ([[returnData objectForKey:@"code"]intValue]==1) {
                                               [self.dataArr removeAllObjects];
                                               [self.arr22 removeAllObjects];
                                               
                                               NSMutableDictionary *dict1 = [returnData objectForKey:@"data"];
                                               _arr22 = [returnData objectForKey:@"data"];
                                               
                                               for (NSDictionary *dic in dict1 ) {
                                                   HomeIntegralMallModel *model = [[HomeIntegralMallModel alloc]init];
                                                   [model setValuesForKeysWithDictionary:dic];
                                                   [_dataArr addObject:model];
                                               }
                                               
                                               
                                               
                                               
                                                    [self.collectionView reloadData];
                                           }
                                           else if ([[returnData objectForKey:@"code"]intValue]==-1){
//                                               [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                           }
                                       } failureBlock:^(NSError *error) {
                                           NSLog(@"%@",error);
                                           [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                                       }];
            
            self.labelOfPop.hidden = YES;
            self.labelOfNew.hidden = YES;
            self.labelOfProgress.hidden = YES;
            self.labelOfPopulation.hidden = NO;
            sender.selected = !sender.selected;
        
            
        }
        

    }

    
}
//轮播图方法
-(void)updateInfo:(NSArray*)SDCycleArr{
    NSMutableArray *myarr=[[NSMutableArray alloc]init];
    for (int i=0; i<SDCycleArr.count; i++) {
        
        NSString *str=[SDCycleArr[i] objectForKey:@"pic"];
        NSString *urlN=manage(AP_HOST, str);
        NSString *strUrl = [urlN stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
        [myarr addObject:strUrl];
    }
    [self.cycleScrollView setLocalizationImageNamesGroup:myarr];
    [self.cycleScrollView reloadInputViews];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
